//
//  LBHorizontalLoopView.h
//  LBHorizontalLoopView
//
//  Created by liubo on 2021/8/29.
//

#import <UIKit/UIKit.h>
#import "LBHorizontalLoopViewCell.h"

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, LBHorizontalLoopViewStyle) {
    ///默认风格，即简单移动轮播
    LBHorizontalLoopViewStyleDefault = 0,
    ///渐隐风格，透明度有变化
    LBHorizontalLoopViewStyleAlphaChange = 1,
};

@class LBHorizontalLoopView;

@protocol LBHorizontalLoopViewDataSource <NSObject>

///轮播视图数量
- (NSInteger)viewNumberOfLoopView:(LBHorizontalLoopView *)loopView;

///返回某个索引对应的轮播视图
- (LBHorizontalLoopViewCell *)cellForIndex:(NSInteger)index inLoopView:(LBHorizontalLoopView *)loopView;

@end

@protocol LBHorizontalLoopViewDelegate <NSObject>

@optional

///点击某个轮播视图
- (void)loopView:(LBHorizontalLoopView *)loopView didClickCellAtIndex:(NSInteger)index;

///滚动到某个索引
- (void)loopView:(LBHorizontalLoopView *)loopView didScrollToCellAtIndex:(NSInteger)index;

///  scroll View滚动
- (void)loopView:(LBHorizontalLoopView *)loopView didScroll:(UIScrollView *)scrollView;

@end

@interface LBHorizontalLoopView : UIView

///数据源
@property (nonatomic, weak) id <LBHorizontalLoopViewDataSource> dataSource;

/// 代理
@property (nonatomic, weak) id <LBHorizontalLoopViewDelegate> delegate;

///当前展示视图的索引
@property (nonatomic, assign, readonly) NSInteger currentIndex;

/// 停止拖动之后是否重新开启计时器，默认YES
@property (nonatomic, assign) BOOL restartTimeEndingDragging;

/// 轮播风格 ，目前支持默认移动风格和透明度变化的渐隐风格
@property (nonatomic, assign) LBHorizontalLoopViewStyle style;

///  轮播时间间隔,  默认3秒
@property (nonatomic, assign) CGFloat duration;

///注册cell
- (void)registerClass:(nonnull Class)cellClass forViewReuseIdentifier:(NSString *)identifier;

///取出cell
- (__kindof LBHorizontalLoopViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;

///刷新数据并开始计时器
- (void)reloadDataAndStartRoll;

///停止计时器
- (void)stopTimer;

@end

NS_ASSUME_NONNULL_END
